package com.example.video.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import java.util.Date;

@Data
@Entity
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners(AuditingEntityListener.class)
public class DeviceInformation {

    /**
     * 联合主键
     */
    @EmbeddedId
    private DeviceInformationPK pk;

    //创建日期
    @CreatedDate
    @Column(name = "collect_date", updatable = false)
    private Date collectDate;

    public DeviceInformation(Device device, Information information) {
        this.pk = new DeviceInformationPK(device, information);
    }

}